<?php

namespace app\frontend\controller;

use app\common\model\BgPosts;
use think\Controller;
use think\Request;

class Search extends Controller
{

    public function index(Request $request)
    {
        //
        $search=trim($request->get('search'));

        if(!$search){
            $search='-';
        }

        $search_info=BgPosts::where('content','like',"%$search%")->whereOr('title','like',"%$search%")->paginate(5,false,[
            'query'=>[
                'search'=>$search
            ]
        ]);
        $this->assign(compact('search','search_info'));
        return $this->fetch();
    }

}
